<?php

/*
	任务列表（工作人员）
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';
$return=array();
if($_RQ['op']=='get'){
	$renwus = array();
	$nowyue = mktime(0,0,0,date('m'),1,date('Y'));
	$renwus['all'] = pdo_count('jy_workline_task',array('uniacid'=>$_SESSION['uniacid']));
	$renwus['day'] = pdo_count('jy_workline_task',array('uniacid'=>$_SESSION['uniacid'],'createtime >'=>$nowyue));
	$workers = pdo_getall('jy_workline_worker',array('uniacid'=>$_SESSION['uniacid']),array('id','mid','name'));
	$workernum = pdo_count('jy_workline_worker',array('uniacid'=>$_SESSION['uniacid']));
	if($workernum){
		$workernum = intval(12 / $workernum);
	}
	foreach($workers as &$row){
		$all = pdo_getall('jy_workline_task',array('uniacid'=>$_SESSION['uniacid'],'getmid'=>$row['mid'],'status'=>2),'credit');
		$alljf=0;
		foreach($all as &$ajf){
			$alljf +=$ajf['credit'];
		}
		$day = pdo_getall('jy_workline_task',array('uniacid'=>$_SESSION['uniacid'],'getmid'=>$row['mid'],'status'=>2,'complete_time >'=>$nowyue),'credit');
		$dayjf=0;
		foreach($day as &$djf){
			$dayjf +=$djf['credit'];
		}
		$row['title'] = $row['name'];
		$row['num'] = 2;
		$row['data'] = array($dayjf,$alljf);
		$allnum = pdo_count('jy_workline_task',array('uniacid'=>$_SESSION['uniacid'],'getmid'=>$row['mid']));
		$row['value'] = $allnum;
	}
	$workersjifen = $workers;
	foreach($workersjifen as &$row){
		$jifen = pdo_getall('jy_workline_task',array('uniacid'=>$_SESSION['uniacid'],'getmid'=>$row['mid'],'status'=>2),array('credit'));
		$row['value'] = 0;
		foreach($jifen as &$v){
			$row['value'] += $v['credit'];
		}
	}
	$return['htmls']=array(
				array('type'=>'data','one_num'=>$workernum,'title'=>'当月/总任务积分指标','datas'=>$workers),
				array('type'=>'echarts_pie','one_num'=>2,'num'=>6,'ecid'=>'wechat','title'=>'员工任务完成数量','datas'=>array(
					'time' => date("Y-m-d H:i:s", time()),
					'datas'=>$workers,
				)),
				array('type'=>'echarts_pie','one_num'=>2,'num'=>6,'ecid'=>'wxapp','title'=>'员工任务获取积分','datas'=>array(
					'time' => date("Y-m-d H:i:s", time()),
					'datas'=>$workersjifen,
				)),
			);
		exi($return);
}
